cmake_minimum_required(VERSION 2.4)
PROJECT(Chat CXX)

SET(CONTROL_DIR controlCentral)
SET(TCP_DIR tcp)
SET(MSG_DIR mensajes)

SET(CMAKE_BUILD_TYPE debug)
SET(CMAKE_CXX_FLAGS "-Wall -I${Chat_BINARY_DIR} -I${Chat_BINARY_DIR}/${TCP_DIR}")
SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb")

SET(IPC_SRC 
  Semaforo.cpp
  Semaforo.h
  Shm.cpp 
  Shm.h
  Cola.cpp
  Cola.h)

SET(LOG_SRC
  log.h
  log.cpp)

SET(COMMON_SRC 
  definiciones.h
  Sesion.cpp 
  Sesion.h
  Conversacion.cpp
  Conversacion.h)

SET(USUARIO_LIB_SRC
  Usuario.cpp
  Usuario.h
  ListaUsuarios.cpp
  ListaUsuarios.h)

ADD_LIBRARY(log_library ${LOG_SRC})
ADD_LIBRARY(ipc_library ${IPC_SRC})
TARGET_LINK_LIBRARIES(ipc_library log_library)

ADD_LIBRARY(usuario_library ${USUARIO_LIB_SRC})
TARGET_LINK_LIBRARIES(usuario_library ipc_library)

ADD_SUBDIRECTORY(${CONTROL_DIR})
ADD_SUBDIRECTORY(${TCP_DIR})
ADD_SUBDIRECTORY(${MSG_DIR})

SET(COMMON_LIBRARIES rpc_cliente_library ipc_library log_library tcp_library mensajes_library usuario_library)

ADD_EXECUTABLE(principal
  principal.cpp 
  ${COMMON_SRC})

TARGET_LINK_LIBRARIES(principal ${COMMON_LIBRARIES})

ADD_EXECUTABLE(editor.out
  editor.cpp
  ${COMMON_SRC})

TARGET_LINK_LIBRARIES(editor.out ${COMMON_LIBRARIES})

ADD_EXECUTABLE(presentador.out
  presentador.cpp
  ${COMMON_SRC})

TARGET_LINK_LIBRARIES(presentador.out ${COMMON_LIBRARIES})

ADD_EXECUTABLE(controlador.out 
  controlador.cpp
  ${COMMON_SRC})

TARGET_LINK_LIBRARIES(controlador.out ${COMMON_LIBRARIES})

ADD_EXECUTABLE(emisor.out 
  emisor.cpp 
  ${COMMON_SRC})

TARGET_LINK_LIBRARIES(emisor.out ${COMMON_LIBRARIES})

ADD_EXECUTABLE(receptor.out
  receptor.cpp 
  ${COMMON_SRC})

TARGET_LINK_LIBRARIES(receptor.out ${COMMON_LIBRARIES})

ADD_EXECUTABLE(receptor_server.out
  receptor_server.cpp 
  ${COMMON_SRC})

TARGET_LINK_LIBRARIES(receptor_server.out ${COMMON_LIBRARIES})

ADD_EXECUTABLE(testftok testftok.cpp)